package com.tianyi.sfzy1.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tianyi.sfzy1.domain.Course;
import com.tianyi.sfzy1.mapper.CourseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * DYT
 */
@Service
public class CourseService {
    @Autowired
    private CourseMapper courseMapper;

//    动态查询所有课程详细信息
    public PageInfo<Course> findAll(String courseName, String consultantName, String courseType,int pageNum,int pageSize){

        PageHelper.startPage(pageNum,pageSize);
        PageInfo<Course> pageInfo=new PageInfo<>(courseMapper.findCourseAll(courseName,consultantName,courseType));
        return pageInfo;
    }

//    根据咨询师id查课程
    public List<Course> findById(int consultantId){
        return courseMapper.findById(consultantId);
    }

//    新增课程
    public int insert(Course course){
        return courseMapper.insert(course);
    }

//    更改课程
    public int update(Course course){
        return courseMapper.update(course);
    }

//    删除课程
    public int delete(int id){
        return courseMapper.delete(id);
    }

//    批量删除课程
    public int deleteSelect(List<Integer> list){
        return courseMapper.deleteSelect(list);
    }


    //   查询课程表购买记录表 已购买
    public List<Course> findCourseAndPayed(){
        return courseMapper.findCourseAndPayed();
    }
    //   查询课程表购买记录表 已购买
    public List<Course> findCourseNotPayed(){
        return courseMapper.findCourseAndNotPayed();
    }

}
